using AutoMapper;
using UwinEducation.Application.Dtos.Orders;
using UwinEducation.Domain.Entities;
using UwinEducation.Shared.Models;

namespace UwinEducation.Application.Mappings
{
    /// <summary>
    /// 订单支付映射配置
    /// </summary>
    public class OrderPaymentProfile : Profile
    {
        /// <summary>
        /// 构造函数，配置映射关系
        /// </summary>
        public OrderPaymentProfile()
        {
            // 实体到DTO的映射
            CreateMap<OrderPayment, OrderPaymentDto>()
                 .ForMember(dest => dest.CreatorName, opt => opt.MapFrom(src => src.Creator.RealName))
                 .ForMember(dest => dest.AuditorName, opt => opt.MapFrom(src => src.Auditor.RealName));

            // 创建DTO到实体的映射
            CreateMap<CreateOrderPaymentDto, OrderPayment>();
                

            // 更新DTO到实体的映射
            CreateMap<UpdateOrderPaymentDto, OrderPayment>()
                .ForMember(dest => dest.OrderId, opt => opt.Ignore()) // 通常不允许修改关联的OrderId
                .ForMember(dest => dest.Order, opt => opt.Ignore()); // 导航属性通常不需要映射

            // 分页请求DTO到仓储层请求模型的映射
            CreateMap<OrderPaymentPageRequestDto, OrderPaymentPageRequest>();
        }
    }
} 